﻿using System;
using ValidationFramework.Reflection;

namespace ValidationFramework
{
	/// <summary>
	/// And interface for cached member reflection information
	/// </summary>
	public interface ICachedReflectionInfo
	{
		/// <summary>
		/// Gets the <see cref="RuntimeTypeHandle"/> for the member this <see cref="InfoDescriptor"/> describes.
		/// </summary>
		/// <remarks>For a <see cref="PropertyDescriptor"/> this will be the <see cref="RuntimeTypeHandle"/> for the return <see cref="Type"/> of the get. For a <see cref="ParameterDescriptor"/> this will be the <see cref="RuntimeTypeHandle"/> for the <see cref="Type"/> of the <see langword="parameter"/>.</remarks>
		RuntimeTypeHandle MemberTypeHandle
		{
			get;
		}

		/// <summary>
		/// Gets the name of the member this cache represents
		/// </summary>
		string Name { get; }

		/// <summary>
		/// Get the value for this <see cref="InfoDescriptor"/>.
		/// </summary>
		/// <param name="instance">The object on which to extract the field value. If a <see cref="InfoDescriptor"/> is static, this argument is ignored.</param>
		/// <returns>The value for the <see cref="InfoDescriptor"/>.</returns>
		object GetValue(object instance);
	}
}
